package com.twoGroup.boot.pojo;

import java.io.Serializable;

/**
 * @ClassName
 * @Description TODO
 * @Author Xuyujie
 * @Date 2021/5/31 10:05
 * @Version 1.0
 **/
public class ResultDate<T> implements Serializable {
    //请求成功为1，请求失败为0；
    private Integer code;
    //回传请求的信息
    private String retMessage;
    //用于携带数据的泛型
    private T t;

    @Override
    public String toString() {
        return "ResultDate{" +
                "code=" + code +
                ", retMessage='" + retMessage + '\'' +
                ", t=" + t +
                '}';
    }

    public static ResultDate success(String retMessage){
        ResultDate resultDate=new ResultDate();
        resultDate.setCode(1);
        resultDate.setRetMessage(retMessage);
        return resultDate;
    }

    public static ResultDate success(String retMessage, Object object){
        ResultDate resultDate=new ResultDate();
        resultDate.setCode(1);
        resultDate.setRetMessage(retMessage);
        resultDate.setT(object);
        return resultDate;
    }

    public static ResultDate fail(String retMessage){
        ResultDate resultDate=new ResultDate();
        resultDate.setCode(0);
        resultDate.setRetMessage(retMessage);
        return resultDate;
    }

    public static ResultDate fail(String retMessage, Object object){
        ResultDate resultDate=new ResultDate();
        resultDate.setRetMessage(retMessage);
        resultDate.setCode(0);
        resultDate.setT(object);
        return resultDate;
    }

    public Integer getCode() {
        return code;
    }

    public void setCode(Integer code) {
        this.code = code;
    }

    public String getRetMessage() {
        return retMessage;
    }

    public void setRetMessage(String retMessage) {
        this.retMessage = retMessage;
    }

    public T getT() {
        return t;
    }

    public void setT(T t) {
        this.t = t;
    }

}
